Skip to content

feat(keyring-eth-ledger-bridge): enhance error handling for Ledger signing operations#294

Merged
ccharly merged 5 commits into
mainfrom
feat/fix-ledger-error-handling
Jun 13, 2025
Merged

feat(keyring-eth-ledger-bridge): enhance error handling for Ledger signing operations#294
ccharly merged 5 commits into
mainfrom
feat/fix-ledger-error-handling

Conversation

@dawnseeker8

Copy link
Copy Markdown
Contributor

Added static method to identify Ledger-specific errors and improved error handling in the LedgerKeyring class. Now, specific error messages are thrown for user-rejected transactions and when blind signing is disabled, providing clearer feedback to users during transaction signing.

Examples

Added static method to identify Ledger-specific errors and improved error handling in the LedgerKeyring class. Now, specific error messages are thrown for user-rejected transactions and when blind signing is disabled, providing clearer feedback to users during transaction signing.
@dawnseeker8 dawnseeker8 added the team-hardware-wallets This should be handled by the Hardware Wallets Team label Jun 9, 2025
@dawnseeker8

Copy link
Copy Markdown
Contributor Author

@metamaskbot publish-preview

@github-actions

github-actions Bot commented Jun 9, 2025

Copy link
Copy Markdown

Preview builds have been published. See these instructions (from the core monorepo) for more information about preview builds.

Expand for full list of packages and versions.
{
  "@metamask-previews/keyring-api": "18.0.0-2d5399c",
  "@metamask-previews/eth-hd-keyring": "12.1.0-2d5399c",
  "@metamask-previews/eth-ledger-bridge-keyring": "11.0.3-2d5399c",
  "@metamask-previews/eth-simple-keyring": "10.0.0-2d5399c",
  "@metamask-previews/eth-trezor-keyring": "8.0.0-2d5399c",
  "@metamask-previews/keyring-internal-api": "6.2.0-2d5399c",
  "@metamask-previews/keyring-internal-snap-client": "4.1.0-2d5399c",
  "@metamask-previews/eth-snap-keyring": "13.0.0-2d5399c",
  "@metamask-previews/keyring-snap-client": "5.0.0-2d5399c",
  "@metamask-previews/keyring-snap-sdk": "4.0.0-2d5399c",
  "@metamask-previews/keyring-utils": "3.0.0-2d5399c"
}

@dawnseeker8

Copy link
Copy Markdown
Contributor Author

@metamaskbot publish-preview

@github-actions

github-actions Bot commented Jun 9, 2025

Copy link
Copy Markdown

Preview builds have been published. See these instructions (from the core monorepo) for more information about preview builds.

Expand for full list of packages and versions.
{
  "@metamask-previews/keyring-api": "18.0.0-8d08f2e",
  "@metamask-previews/eth-hd-keyring": "12.1.0-8d08f2e",
  "@metamask-previews/eth-ledger-bridge-keyring": "11.0.3-8d08f2e",
  "@metamask-previews/eth-simple-keyring": "10.0.0-8d08f2e",
  "@metamask-previews/eth-trezor-keyring": "8.0.0-8d08f2e",
  "@metamask-previews/keyring-internal-api": "6.2.0-8d08f2e",
  "@metamask-previews/keyring-internal-snap-client": "4.1.0-8d08f2e",
  "@metamask-previews/eth-snap-keyring": "13.0.0-8d08f2e",
  "@metamask-previews/keyring-snap-client": "5.0.0-8d08f2e",
  "@metamask-previews/keyring-snap-sdk": "4.0.0-8d08f2e",
  "@metamask-previews/keyring-utils": "3.0.0-8d08f2e"
}

@dawnseeker8

Copy link
Copy Markdown
Contributor Author

@metamaskbot publish-preview

@github-actions

github-actions Bot commented Jun 9, 2025

Copy link
Copy Markdown

Preview builds have been published. See these instructions (from the core monorepo) for more information about preview builds.

Expand for full list of packages and versions.
{
  "@metamask-previews/keyring-api": "18.0.0-87ad186",
  "@metamask-previews/eth-hd-keyring": "12.1.0-87ad186",
  "@metamask-previews/eth-ledger-bridge-keyring": "11.0.3-87ad186",
  "@metamask-previews/eth-simple-keyring": "10.0.0-87ad186",
  "@metamask-previews/eth-trezor-keyring": "8.0.0-87ad186",
  "@metamask-previews/keyring-internal-api": "6.2.0-87ad186",
  "@metamask-previews/keyring-internal-snap-client": "4.1.0-87ad186",
  "@metamask-previews/eth-snap-keyring": "13.0.0-87ad186",
  "@metamask-previews/keyring-snap-client": "5.0.0-87ad186",
  "@metamask-previews/keyring-snap-sdk": "4.0.0-87ad186",
  "@metamask-previews/keyring-utils": "3.0.0-87ad186"
}

Added tests to handle specific TransportStatusError codes for user rejection and blind signing scenarios in transaction signing, personal message signing, and typed data signing. This improves the robustness of error handling in the LedgerKeyring class.
@dawnseeker8 dawnseeker8 marked this pull request as ready for review June 10, 2025 03:43
@dawnseeker8 dawnseeker8 requested review from a team as code owners June 10, 2025 03:43
@dawnseeker8

Copy link
Copy Markdown
Contributor Author

@metamaskbot publish-preview

@github-actions

Copy link
Copy Markdown

Preview builds have been published. See these instructions (from the core monorepo) for more information about preview builds.

Expand for full list of packages and versions.
{
  "@metamask-previews/keyring-api": "18.0.0-fc10452",
  "@metamask-previews/eth-hd-keyring": "12.1.0-fc10452",
  "@metamask-previews/eth-ledger-bridge-keyring": "11.0.3-fc10452",
  "@metamask-previews/eth-simple-keyring": "10.0.0-fc10452",
  "@metamask-previews/eth-trezor-keyring": "8.0.0-fc10452",
  "@metamask-previews/keyring-internal-api": "6.2.0-fc10452",
  "@metamask-previews/keyring-internal-snap-client": "4.1.0-fc10452",
  "@metamask-previews/eth-snap-keyring": "13.0.0-fc10452",
  "@metamask-previews/keyring-snap-client": "5.0.0-fc10452",
  "@metamask-previews/keyring-snap-sdk": "4.0.0-fc10452",
  "@metamask-previews/keyring-utils": "3.0.0-fc10452"
}

Comment thread packages/keyring-eth-ledger-bridge/src/ledger-keyring.ts
Comment thread packages/keyring-eth-ledger-bridge/src/ledger-keyring.ts
Comment thread packages/keyring-eth-ledger-bridge/src/ledger-keyring.ts

@ccharly ccharly left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had suggestions for this to use a function to avoid code-duplication, but this is blocking other things right now, so I'm ok with doing this improvements on a future PR 😄

@ccharly ccharly enabled auto-merge June 13, 2025 10:07
@ccharly ccharly added this pull request to the merge queue Jun 13, 2025
@ccharly ccharly removed this pull request from the merge queue due to a manual request Jun 13, 2025
@ccharly ccharly changed the title feat: enhance error handling for Ledger transactions feat(keyring-eth-ledger-bridge): enhance error handling for Ledger signing operations Jun 13, 2025
@ccharly ccharly added this pull request to the merge queue Jun 13, 2025
Merged via the queue into main with commit 83cfce6 Jun 13, 2025
32 checks passed
@ccharly ccharly deleted the feat/fix-ledger-error-handling branch June 13, 2025 10:12
github-merge-queue Bot pushed a commit to MetaMask/metamask-mobile that referenced this pull request Jun 25, 2025
<!--
Please submit this PR as a draft initially.
Do not mark it as "Ready for review" until the template has been
completely filled out, and PR status checks have passed at least once.
-->

## **Description**
This PR will fix issue #13165 
This PR will upgrade @metamask/eth-ledger-keyring-bridge library to
correctly handle the blind signing not enable error and user reject
transaction error.

This PR will wait library upgrade PR merged and release first.
MetaMask/accounts#294

<!--
Write a short description of the changes included in this pull request,
also include relevant motivation and context. Have in mind the following
questions:
1. What is the reason for the change?
2. What is the improvement/solution?
-->

## **Related issues**

Fixes: #13165 

## **Manual testing steps**

1. Install MM Mobile
2. Recover from SRP
3. Add hardware wallet (Ledger Stax)
4. Add Ledger account from account list
5. Launch MM Test dApp
6. Connect with Ledger account
7. Disable blind signing on Ledger device
8. Sign typed data v4
9. Verify error

## **Screenshots/Recordings**

<!-- If applicable, add screenshots and/or recordings to visualize the
before and after of your change. -->

### **Before**

<!-- [screenshots/recordings] -->

### **After**

<!-- [screenshots/recordings] -->

## **Pre-merge author checklist**

- [x] I’ve followed [MetaMask Contributor
Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Mobile
Coding
Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/CODING_GUIDELINES.md).
- [x] I've completed the PR template to the best of my ability
- [x] I’ve included tests if applicable
- [x] I’ve documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [x] I’ve applied the right labels on the PR (see [labeling
guidelines](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/LABELING_GUIDELINES.md)).
Not required for external contributors.

## **Pre-merge reviewer checklist**

- [x] I've manually tested the PR (e.g. pull and build branch, run the
app, test code being changed).
- [x] I confirm that this PR addresses all acceptance criteria described
in the ticket it closes and includes the necessary testing evidence such
as recordings and or screenshots.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

team-hardware-wallets This should be handled by the Hardware Wallets Team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants